<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="主表id" prop="excelId">
        <el-input v-model="queryParams.excelId" placeholder="请输入主表id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筛分后总质量∑mi" prop="shaifhzzlItem1">
        <el-input v-model="queryParams.shaifhzzlItem1" placeholder="请输入筛分后总质量∑mi" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="损耗m5" prop="sunhItem1">
        <el-input v-model="queryParams.sunhItem1" placeholder="请输入损耗m5" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="损耗率" prop="sunhlItem1">
        <el-input v-model="queryParams.sunhlItem1" placeholder="请输入损耗率" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筛分后总质量∑mi" prop="shaifhzzlItem2">
        <el-input v-model="queryParams.shaifhzzlItem2" placeholder="请输入筛分后总质量∑mi" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="损耗m5" prop="sunhItem2">
        <el-input v-model="queryParams.sunhItem2" placeholder="请输入损耗m5" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="损耗率" prop="sunhlItem2">
        <el-input v-model="queryParams.sunhlItem2" placeholder="请输入损耗率" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筛孔尺寸(mm)" prop="shaikcc">
        <el-input v-model="queryParams.shaikcc" placeholder="请输入筛孔尺寸(mm)" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="称量次数分组1" prop="chenglcsItem1">
        <el-input v-model="queryParams.chenglcsItem1" placeholder="请输入称量次数分组1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="质量m0分组1" prop="zhilItem1">
        <el-input v-model="queryParams.zhilItem1" placeholder="请输入质量m0分组1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筛上质量mi(g)分组1" prop="shaiszlItem1">
        <el-input v-model="queryParams.shaiszlItem1" placeholder="请输入筛上质量mi(g)分组1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="分计筛余(%)分组1" prop="fenjsyItem1">
        <el-input v-model="queryParams.fenjsyItem1" placeholder="请输入分计筛余(%)分组1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="累计筛余(%)分组1" prop="leijsyItem1">
        <el-input v-model="queryParams.leijsyItem1" placeholder="请输入累计筛余(%)分组1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="通过百分率(%)分组1" prop="tonggbflItem1">
        <el-input v-model="queryParams.tonggbflItem1" placeholder="请输入通过百分率(%)分组1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="称量次数分组2" prop="chenglcsItem2">
        <el-input v-model="queryParams.chenglcsItem2" placeholder="请输入称量次数分组2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="质量m0分组2" prop="zhilItem2">
        <el-input v-model="queryParams.zhilItem2" placeholder="请输入质量m0分组2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筛上质量mi(g)分组2" prop="shaiszlItem2">
        <el-input v-model="queryParams.shaiszlItem2" placeholder="请输入筛上质量mi(g)分组2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="分计筛余(%)分组2" prop="fenjsyItem2">
        <el-input v-model="queryParams.fenjsyItem2" placeholder="请输入分计筛余(%)分组2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="累计筛余(%)分组2" prop="leijsyItem2">
        <el-input v-model="queryParams.leijsyItem2" placeholder="请输入累计筛余(%)分组2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="通过百分率(%)分组2" prop="tonggbflItem2">
        <el-input v-model="queryParams.tonggbflItem2" placeholder="请输入通过百分率(%)分组2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="平均累计筛余百分率(%)" prop="leijsybflPzh">
        <el-input v-model="queryParams.leijsybflPzh" placeholder="请输入平均累计筛余百分率(%)" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb5 top-right-btn small-line-height">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['report_jl:jlCjlsfgsfjlbBaDetail:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['report_jl:jlCjlsfgsfjlbBaDetail:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['report_jl:jlCjlsfgsfjlbBaDetail:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['report_jl:jlCjlsfgsfjlbBaDetail:export']">导出</el-button>
      </el-col>
      <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
    </el-row>

    <el-table border stripe v-loading="loading" :data="jlCjlsfgsfjlbBaDetailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="detailId" v-if="true" />
      <el-table-column label="主表id" align="center" prop="excelId" />
      <el-table-column label="筛分后总质量∑mi" align="center" prop="shaifhzzlItem1" />
      <el-table-column label="损耗m5" align="center" prop="sunhItem1" />
      <el-table-column label="损耗率" align="center" prop="sunhlItem1" />
      <el-table-column label="筛分后总质量∑mi" align="center" prop="shaifhzzlItem2" />
      <el-table-column label="损耗m5" align="center" prop="sunhItem2" />
      <el-table-column label="损耗率" align="center" prop="sunhlItem2" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="筛孔尺寸(mm)" align="center" prop="shaikcc" />
      <el-table-column label="称量次数分组1" align="center" prop="chenglcsItem1" />
      <el-table-column label="质量m0分组1" align="center" prop="zhilItem1" />
      <el-table-column label="筛上质量mi(g)分组1" align="center" prop="shaiszlItem1" />
      <el-table-column label="分计筛余(%)分组1" align="center" prop="fenjsyItem1" />
      <el-table-column label="累计筛余(%)分组1" align="center" prop="leijsyItem1" />
      <el-table-column label="通过百分率(%)分组1" align="center" prop="tonggbflItem1" />
      <el-table-column label="称量次数分组2" align="center" prop="chenglcsItem2" />
      <el-table-column label="质量m0分组2" align="center" prop="zhilItem2" />
      <el-table-column label="筛上质量mi(g)分组2" align="center" prop="shaiszlItem2" />
      <el-table-column label="分计筛余(%)分组2" align="center" prop="fenjsyItem2" />
      <el-table-column label="累计筛余(%)分组2" align="center" prop="leijsyItem2" />
      <el-table-column label="通过百分率(%)分组2" align="center" prop="tonggbflItem2" />
      <el-table-column label="平均累计筛余百分率(%)" align="center" prop="leijsybflPzh" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['report_jl:jlCjlsfgsfjlbBaDetail:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['report_jl:jlCjlsfgsfjlbBaDetail:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改粗集料筛分试验检测记录（干筛法）详情对话框 -->
    <jy-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主表id" prop="excelId">
          <el-input v-model="form.excelId" placeholder="请输入主表id" />
        </el-form-item>
        <el-form-item label="筛分后总质量∑mi" prop="shaifhzzlItem1">
          <el-input v-model="form.shaifhzzlItem1" placeholder="请输入筛分后总质量∑mi" />
        </el-form-item>
        <el-form-item label="损耗m5" prop="sunhItem1">
          <el-input v-model="form.sunhItem1" placeholder="请输入损耗m5" />
        </el-form-item>
        <el-form-item label="损耗率" prop="sunhlItem1">
          <el-input v-model="form.sunhlItem1" placeholder="请输入损耗率" />
        </el-form-item>
        <el-form-item label="筛分后总质量∑mi" prop="shaifhzzlItem2">
          <el-input v-model="form.shaifhzzlItem2" placeholder="请输入筛分后总质量∑mi" />
        </el-form-item>
        <el-form-item label="损耗m5" prop="sunhItem2">
          <el-input v-model="form.sunhItem2" placeholder="请输入损耗m5" />
        </el-form-item>
        <el-form-item label="损耗率" prop="sunhlItem2">
          <el-input v-model="form.sunhlItem2" placeholder="请输入损耗率" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="筛孔尺寸(mm)" prop="shaikcc">
          <el-input v-model="form.shaikcc" placeholder="请输入筛孔尺寸(mm)" />
        </el-form-item>
        <el-form-item label="称量次数分组1" prop="chenglcsItem1">
          <el-input v-model="form.chenglcsItem1" placeholder="请输入称量次数分组1" />
        </el-form-item>
        <el-form-item label="质量m0分组1" prop="zhilItem1">
          <el-input v-model="form.zhilItem1" placeholder="请输入质量m0分组1" />
        </el-form-item>
        <el-form-item label="筛上质量mi(g)分组1" prop="shaiszlItem1">
          <el-input v-model="form.shaiszlItem1" placeholder="请输入筛上质量mi(g)分组1" />
        </el-form-item>
        <el-form-item label="分计筛余(%)分组1" prop="fenjsyItem1">
          <el-input v-model="form.fenjsyItem1" placeholder="请输入分计筛余(%)分组1" />
        </el-form-item>
        <el-form-item label="累计筛余(%)分组1" prop="leijsyItem1">
          <el-input v-model="form.leijsyItem1" placeholder="请输入累计筛余(%)分组1" />
        </el-form-item>
        <el-form-item label="通过百分率(%)分组1" prop="tonggbflItem1">
          <el-input v-model="form.tonggbflItem1" placeholder="请输入通过百分率(%)分组1" />
        </el-form-item>
        <el-form-item label="称量次数分组2" prop="chenglcsItem2">
          <el-input v-model="form.chenglcsItem2" placeholder="请输入称量次数分组2" />
        </el-form-item>
        <el-form-item label="质量m0分组2" prop="zhilItem2">
          <el-input v-model="form.zhilItem2" placeholder="请输入质量m0分组2" />
        </el-form-item>
        <el-form-item label="筛上质量mi(g)分组2" prop="shaiszlItem2">
          <el-input v-model="form.shaiszlItem2" placeholder="请输入筛上质量mi(g)分组2" />
        </el-form-item>
        <el-form-item label="分计筛余(%)分组2" prop="fenjsyItem2">
          <el-input v-model="form.fenjsyItem2" placeholder="请输入分计筛余(%)分组2" />
        </el-form-item>
        <el-form-item label="累计筛余(%)分组2" prop="leijsyItem2">
          <el-input v-model="form.leijsyItem2" placeholder="请输入累计筛余(%)分组2" />
        </el-form-item>
        <el-form-item label="通过百分率(%)分组2" prop="tonggbflItem2">
          <el-input v-model="form.tonggbflItem2" placeholder="请输入通过百分率(%)分组2" />
        </el-form-item>
        <el-form-item label="平均累计筛余百分率(%)" prop="leijsybflPzh">
          <el-input v-model="form.leijsybflPzh" placeholder="请输入平均累计筛余百分率(%)" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button size="small" @click="cancel">取 消</el-button>
      </div>
    </jy-dialog>
  </div>
</template>

<script>
import { listJlCjlsfgsfjlbBaDetail, getJlCjlsfgsfjlbBaDetail, delJlCjlsfgsfjlbBaDetail, addJlCjlsfgsfjlbBaDetail, updateJlCjlsfgsfjlbBaDetail } from "@/api/report_jl/jlCjlsfgsfjlbBaDetail";

export default {
  name: "JlCjlsfgsfjlbBaDetail",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 粗集料筛分试验检测记录（干筛法）详情表格数据
      jlCjlsfgsfjlbBaDetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        excelId: undefined,
        shaifhzzlItem1: undefined,
        sunhItem1: undefined,
        sunhlItem1: undefined,
        shaifhzzlItem2: undefined,
        sunhItem2: undefined,
        sunhlItem2: undefined,
        shaikcc: undefined,
        chenglcsItem1: undefined,
        zhilItem1: undefined,
        shaiszlItem1: undefined,
        fenjsyItem1: undefined,
        leijsyItem1: undefined,
        tonggbflItem1: undefined,
        chenglcsItem2: undefined,
        zhilItem2: undefined,
        shaiszlItem2: undefined,
        fenjsyItem2: undefined,
        leijsyItem2: undefined,
        tonggbflItem2: undefined,
        leijsybflPzh: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        detailId: [{ required: true, message: "id不能为空", trigger: "blur" }],
        excelId: [{ required: true, message: "主表id不能为空", trigger: "blur" }],
        shaifhzzlItem1: [{ required: true, message: "筛分后总质量∑mi不能为空", trigger: "blur" }],
        sunhItem1: [{ required: true, message: "损耗m5不能为空", trigger: "blur" }],
        sunhlItem1: [{ required: true, message: "损耗率不能为空", trigger: "blur" }],
        shaifhzzlItem2: [{ required: true, message: "筛分后总质量∑mi不能为空", trigger: "blur" }],
        sunhItem2: [{ required: true, message: "损耗m5不能为空", trigger: "blur" }],
        sunhlItem2: [{ required: true, message: "损耗率不能为空", trigger: "blur" }],
        remark: [{ required: true, message: "备注不能为空", trigger: "blur" }],
        shaikcc: [{ required: true, message: "筛孔尺寸(mm)不能为空", trigger: "blur" }],
        chenglcsItem1: [{ required: true, message: "称量次数分组1不能为空", trigger: "blur" }],
        zhilItem1: [{ required: true, message: "质量m0分组1不能为空", trigger: "blur" }],
        shaiszlItem1: [{ required: true, message: "筛上质量mi(g)分组1不能为空", trigger: "blur" }],
        fenjsyItem1: [{ required: true, message: "分计筛余(%)分组1不能为空", trigger: "blur" }],
        leijsyItem1: [{ required: true, message: "累计筛余(%)分组1不能为空", trigger: "blur" }],
        tonggbflItem1: [{ required: true, message: "通过百分率(%)分组1不能为空", trigger: "blur" }],
        chenglcsItem2: [{ required: true, message: "称量次数分组2不能为空", trigger: "blur" }],
        zhilItem2: [{ required: true, message: "质量m0分组2不能为空", trigger: "blur" }],
        shaiszlItem2: [{ required: true, message: "筛上质量mi(g)分组2不能为空", trigger: "blur" }],
        fenjsyItem2: [{ required: true, message: "分计筛余(%)分组2不能为空", trigger: "blur" }],
        leijsyItem2: [{ required: true, message: "累计筛余(%)分组2不能为空", trigger: "blur" }],
        tonggbflItem2: [{ required: true, message: "通过百分率(%)分组2不能为空", trigger: "blur" }],
        leijsybflPzh: [{ required: true, message: "平均累计筛余百分率(%)不能为空", trigger: "blur" }]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询粗集料筛分试验检测记录（干筛法）详情列表 */
    getList() {
      this.loading = true;
      listJlCjlsfgsfjlbBaDetail(this.queryParams).then((response) => {
        this.jlCjlsfgsfjlbBaDetailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        detailId: undefined,
        excelId: undefined,
        delFlag: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined,
        shaifhzzlItem1: undefined,
        sunhItem1: undefined,
        sunhlItem1: undefined,
        shaifhzzlItem2: undefined,
        sunhItem2: undefined,
        sunhlItem2: undefined,
        remark: undefined,
        shaikcc: undefined,
        chenglcsItem1: undefined,
        zhilItem1: undefined,
        shaiszlItem1: undefined,
        fenjsyItem1: undefined,
        leijsyItem1: undefined,
        tonggbflItem1: undefined,
        chenglcsItem2: undefined,
        zhilItem2: undefined,
        shaiszlItem2: undefined,
        fenjsyItem2: undefined,
        leijsyItem2: undefined,
        tonggbflItem2: undefined,
        leijsybflPzh: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.detailId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加粗集料筛分试验检测记录（干筛法）详情";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const detailId = row.detailId || this.ids;
      getJlCjlsfgsfjlbBaDetail(detailId).then((response) => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改粗集料筛分试验检测记录（干筛法）详情";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.detailId != null) {
            updateJlCjlsfgsfjlbBaDetail(this.form)
              .then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              })
              .finally(() => {
                this.buttonLoading = false;
              });
          } else {
            addJlCjlsfgsfjlbBaDetail(this.form)
              .then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              })
              .finally(() => {
                this.buttonLoading = false;
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const detailIds = row.detailId || this.ids;
      this.$modal
        .confirm('是否确认删除粗集料筛分试验检测记录（干筛法）详情编号为"' + detailIds + '"的数据项？')
        .then(() => {
          this.loading = true;
          return delJlCjlsfgsfjlbBaDetail(detailIds);
        })
        .then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {})
        .finally(() => {
          this.loading = false;
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "report_jl/jlCjlsfgsfjlbBaDetail/export",
        {
          ...this.queryParams
        },
        `jlCjlsfgsfjlbBaDetail_${new Date().getTime()}.xlsx`
      );
    }
  }
};
</script>
